﻿package 
{
    import com.lang.*;
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.text.*;

    public class Index extends Sprite
    {
        private var _tf:TextField;
        private var _l:Loader;
        private var _e:Loader;
        public var args:Object;

        public function Index()
        {
            this.args = {};
            addEventListener(Event.ADDED_TO_STAGE, this.addedToStage);
            return;
        }// end function

        private function addedToStage(event:Event) : void
        {
            var _loc_4:String = null;
            var _loc_5:String = null;
            var _loc_6:URLRequest = null;
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            this._tf = new TextField();
            addChild(this._tf);
            this._tf.autoSize = TextFieldAutoSize.LEFT;
            this._tf.text = IndexLang.Init;
            this._tf.textColor = 16777215;
            this._tf.selectable = false;
            var _loc_2:String = "?";
            var _loc_3:* = stage.loaderInfo.parameters;
            for (_loc_4 in _loc_3)
            {
                
                if (_loc_4 == "rnd")
                {
                    _loc_2 = _loc_2 + ("rnd=" + _loc_3["rnd"]);
                    continue;
                }
                this.args[_loc_4] = _loc_3[_loc_4] || "";
            }
            _loc_5 = this.args["client_url"] || Config.ResourcesPathPrefix;
            this._e = new Loader();
            addChild(this._e);
            this._e.load(new URLRequest(_loc_5 + "assets/init_effect.swf"));
            this._l = new Loader();
            this.addEvent();
            _loc_6 = new URLRequest(_loc_5 + "Main.swf" + _loc_2);
            this._l.load(_loc_6);
            this.center();
            stage.addEventListener(Event.RESIZE, this.center);
            return;
        }// end function

        private function center(event:Event = null) : void
        {
            this._tf.x = (stage.stageWidth - this._tf.width) / 2;
            this._tf.y = (stage.stageHeight - this._tf.height) / 2;
            this._e.x = (stage.stageWidth - 40) / 2;
            this._e.y = this._tf.y - 40 - 5;
            return;
        }// end function

        private function addEvent() : void
        {
            var _loc_1:* = this._l.contentLoaderInfo;
            var _loc_2:* = this._e.contentLoaderInfo;
            _loc_1.addEventListener(Event.COMPLETE, this.ch);
            _loc_2.addEventListener(HTTPStatusEvent.HTTP_STATUS, this.hsh);
            _loc_2.addEventListener(Event.INIT, this.ih);
            _loc_2.addEventListener(IOErrorEvent.IO_ERROR, this.ieh);
            _loc_2.addEventListener(Event.OPEN, this.oh);
            _loc_2.addEventListener(ProgressEvent.PROGRESS, this.ph);
            _loc_2.addEventListener(Event.UNLOAD, this.uh);
            return;
        }// end function

        private function removeEvent() : void
        {
            var _loc_1:* = this._l.contentLoaderInfo;
            var _loc_2:* = this._e.contentLoaderInfo;
            _loc_1.removeEventListener(Event.COMPLETE, this.ch);
            _loc_2.removeEventListener(HTTPStatusEvent.HTTP_STATUS, this.hsh);
            _loc_2.removeEventListener(Event.INIT, this.ih);
            _loc_2.removeEventListener(IOErrorEvent.IO_ERROR, this.ieh);
            _loc_2.removeEventListener(Event.OPEN, this.oh);
            _loc_2.removeEventListener(ProgressEvent.PROGRESS, this.ph);
            _loc_2.removeEventListener(Event.UNLOAD, this.uh);
            return;
        }// end function

        private function ch(event:Event) : void
        {
            this.removeEvent();
            stage.removeEventListener(Event.RESIZE, this.center);
            stage.addChild(this._l.content);
            this._l = null;
            return;
        }// end function

        private function hsh(event:HTTPStatusEvent) : void
        {
            return;
        }// end function

        private function ih(event:Event) : void
        {
            return;
        }// end function

        private function ieh(event:IOErrorEvent) : void
        {
            return;
        }// end function

        private function oh(event:Event) : void
        {
            return;
        }// end function

        private function ph(event:ProgressEvent) : void
        {
            return;
        }// end function

        private function uh(event:Event) : void
        {
            return;
        }// end function

    }
}
